/**
 * 
 */
package machineLearning.featurecalculator;

import java.util.List;

import machineLearning.SentenceExampleBuilder;


import rainbownlp.core.Artifact;
import rainbownlp.core.FeatureValuePair;
import rainbownlp.core.Phrase;
import rainbownlp.core.PhraseLink;
import rainbownlp.i2b2.sharedtask2012.SecTimeEventExampleBuilder;
import rainbownlp.machineLearning.IFeatureCalculator;
import rainbownlp.machineLearning.MLExample;
import rainbownlp.machineLearning.MLExampleFeature;
import rainbownlp.util.StringUtil;



/**
 * @author azadeh
 * 
 */
public class NGrams implements IFeatureCalculator {
	
	public static void main(String[] args) throws Exception
	{
		
		String experimentgroup =SentenceExampleBuilder.experimentGroup;
		List<MLExample> trainExamples = 
			MLExample.getAllExamples(experimentgroup, true);
		
		for ( MLExample example_to_process: trainExamples )
		{
			NGrams n_grams =  new NGrams();
			
			n_grams.calculateFeatures(example_to_process);
		}
		
		
		
	}
		@Override
	public void calculateFeatures(MLExample exampleToProcess) {
		Artifact sent=	exampleToProcess.getRelatedArtifact();
		System.out.println(sent.getContent());
		
		String[] word_text = sent.getContent().split(" ");
			
		for(int i=0;i<word_text.length;i++)
		{
			String cur_content = StringUtil.getTermByTermWordnet(word_text[i].trim().trim());
			for(int n=2;n<4;n++)
			{
				int new_part_index = i+n-1;
				if(new_part_index<word_text.length && !word_text[new_part_index].trim().equals(""))
				{
					String content = StringUtil.getTermByTermWordnet(word_text[new_part_index].trim());
					cur_content = 
						cur_content.concat("_"+content);
					FeatureValuePair value_pair = FeatureValuePair.getInstance(
							"NonNormalizedNGram"+n, cur_content, "1");
					MLExampleFeature.setFeatureExample(exampleToProcess,value_pair);
			
				}
			}
		}
				
	}
		
		
		

	
}
